<!Doctype html>
<html>

<head>
    <title>oixan的博客</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Content-Type" content="text/html" ; charset="utf-8">
    <link rel="stylesheet" type="text/css" href="../css/blog.css">
</head>

<body>
    <div class="head">
        <div class="headnav">
            <div class="naveframe">
                <ul class="navlist">
                    <li>
                        <a href="../index.html">
                            主页
                        </a>
                    </li>
                    <li>
                        <a href="../bloglist.html">
                            博客
                        </a>
                    </li>
                    <li>
                        <a href="../about.html">
                            关于
                        </a>
                    </li>
                </ul>
            </div>
        </div>

        <div class="headtext">
            <div class="headtext1">世界很简单，人类很复杂。</div>
            <div class="headtext2">浮生若梦，寻寻觅觅。</div>
        </div>
    </div>

    <div class="contents-all">
        <div class="contents">

            <div class="frame">
                <div class="title">
                    <h3>excel2007批量插入图片</h3>
                </div>
                <div class="dtime">时间：2018-06-07</div>
                <div class="detail">

                    <p>
                        excel2007批量插入图片，vba代码（转）
                    </p>
                    <p>
                        <br/>
                    </p>
                    <p>
                        <span style="font-size: 12px;">Sub 批量插入图片()</span>
                    </p>
                    <p>
                        <span style="font-size: 12px;">Dim address As String</span>
                    </p>
                    <p>
                        <span style="font-size: 12px;">Dim cellcolumn, piccolumn As Integer</span>
                    </p>
                    <p>
                        <span style="font-size: 12px;">On Error Resume Next &#39;容错处理</span>
                    </p>
                    <p>
                        <span style="font-size: 12px;">address = &quot;D:\chat\p\&quot;&nbsp; &nbsp;&#39;图片文件夹所在的位置，根据图片位置修改</span>
                    </p>
                    <p>
                        <span style="font-size: 12px;">cellcolumn = 1&nbsp; &#39;设置款号所在列，根据自己实际情况修改</span>
                    </p>
                    <p>
                        <span style="font-size: 12px;">piccolumn = 4&nbsp; &#39;设置插入图片所在第几列，根据自己实际情况修改</span>
                    </p>
                    <p>
                        <span style="font-size: 12px;">Application.ScreenUpdating = False &#39;关闭屏幕更新，提升速度</span>
                    </p>
                    <p>
                        <span style="font-size: 12px;">For i = 2 To Range(&quot;A65536&quot;).End(xlUp).Row&nbsp; &#39;数字2是设置开始填充图片的行号是第二行，根据实际情况修改</span><span style="font-size: 12px;">&nbsp;&nbsp;</span><br/>
                    </p>
                    <p>
                        <span style="font-size: 12px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Cells(i, piccolumn).Select</span>
                    </p>
                    <p>
                        <span style="font-size: 12px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Cells(i, piccolumn) = Cells(i, cellcolumn) &#39;图片所在单元格必须有数据才能支持排序</span>
                    </p>
                    <p>
                        <span style="font-size: 12px;">&nbsp; &nbsp; &nbsp; &nbsp;ActiveSheet.Shapes.AddShape(msoShapeRectangle, (Cells(i, piccolumn).Left + 2.5),&nbsp;</span>
                    </p>
                    <p>
                        <span style="font-size: 12px;">&nbsp; &nbsp; &nbsp; (Cells(i, piccolumn).Top + 2),&nbsp;</span>
                    </p>
                    <p>
                        <span style="font-size: 12px;">&nbsp; &nbsp; &nbsp; (Cells(i, piccolumn).Width - 5),&nbsp;</span>
                    </p>
                    <p>
                        <span style="font-size: 12px;">&nbsp; &nbsp; &nbsp; (Cells(i, piccolumn).Height - 4)).Fill.UserPicture address &amp; &quot;\&quot; &amp; Cells(i, cellcolumn).Text &amp; &quot;.jpg&quot;</span>
                    </p>
                    <p>
                        <span style="font-size: 12px;">&nbsp;&#39;填充图片 &#39;图片格式必须为*.jpg格式，如果为其他格式，在这里更改图片格式</span><span style="font-size: 12px;">&nbsp;</span>
                    </p>
                    <p>
                        <span style="font-size: 12px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Selection.ShapeRange.LockAspectRatio = msoTrue</span>
                    </p>
                    <p>
                        <span style="font-size: 12px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Selection.ShapeRange.Rotation = 0#</span>
                    </p>
                    <p>
                        <span style="font-size: 12px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Selection.Placement = xlMoveAndSize</span>
                    </p>
                    <p>
                        <span style="font-size: 12px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Selection.PrintObject = True</span>
                    </p>
                    <p>
                        <span style="font-size: 12px;">&nbsp; &nbsp;Next i</span><span style="font-size: 12px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span>
                    </p>
                    <p>
                        <span style="font-size: 12px;">&nbsp; &nbsp;Application.ScreenUpdating = True &#39;打开屏幕更新</span>
                    </p>
                    <p>
                        <span style="font-size: 12px;">End Sub</span>
                    </p>
                    <p>
                        <br/>
                    </p>

                </div>
<a href="javascript:void(0)" onclick="showPg()">返回</a>
            </div>






        </div>
    </div>
    <div class="footer">
        <div class="footertext">©2018,oixan博客</div>
    </div>
    <span id="backtop" onclick="topFunction()">返回顶部</span>
</body>
<script  src="../js/fanhuiye.js"></script>
</html>